// Copyright (c) 2006 Zorm
// Released under the MIT License

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#pragma once

#if UNICODE
	#define STREAMFLAGS SF_UNICODE
#else
	#define STREAMFLAGS 0
#endif

#define WM_MOUSEWHEEL 0x020A

class MainWindow : public Window {

public:
	MainWindow(HINSTANCE instance) : m_textToAppendSize(0), m_sizeOfTextToAppend(0), m_cColor(0), m_tabCount(1) { m_pgmInstance = instance; LoadColors(); }
	bool CreateWindows();
	void TimeStamp();
	void SetColor(COLORREF color);
	void AddText(TCHAR *format, ...);
	int AddTab(TCHAR *text);
	void Update();
	void RedrawRadar() { InvalidateRect(m_staticHWND, NULL, false); }
	void SetLatLon(double lat, double lon);
	void SetLatLon();
	HWND GetStaticHWND() { return m_staticHWND; }
	
	enum {
		CWHITE,
		CGREY,
		CBLUE,
		CGREEN,
		CRED,
		CYELLOW,
		CPURPLE,
		CBLUEGREEN,
		CMIDBLUE,
		CDARKBLUE,
		CDARKGREEN,
		CDARKYELLOW,
		CDARKRED,
		CDARKPURPLE,
		CLIGHTBLUE
	};
	
protected:
	LRESULT HandleMessage(UINT message, WPARAM wParam, LPARAM lParam);
	LRESULT CALLBACK StaticSubclass(UINT msg, WPARAM wParam, LPARAM lParam);
	
private:
	LPCTSTR ClassName() { return TEXT("ATHClass"); }
	LPCTSTR WindowName() { return TEXT("Anticipating The Hook"); }
	void LoadColors();
	DWORD EditCallback(LPBYTE pbBuff, LONG cb, LONG *pcb);
	
	HWND m_tabHWND, m_statusHWND, m_richEditHWND, m_staticHWND;
	HANDLE m_richEditDLL;
	
	HMENU m_menuBar, m_fileMenu;
	
	WNDPROC m_staticProc;
	
	int m_activeTab, m_tabCount;
	TCHAR m_txtToAppend[4096];
	size_t m_textToAppendSize;
	unsigned long m_sizeOfTextToAppend;
	COLORREF m_cColor;
	COLORREF m_colors[15];
	CHARFORMAT m_cfFormat;
	
	static DWORD CALLBACK EditStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
	static LRESULT CALLBACK StaticSubclassStatic(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

	enum {
		MENU_START = 100,
		#define ADDMENUCHILD(a, b, c, d)
		#define ADDMENU(a, b, c, d) MENU_##c,
		#include "menus.tbl"
		#undef ADDMENU
		#undef ADDMENUCHILD
		MENU_QTY,
	};

};

#endif
